/*
 * Created by SharpDevelop.
 * User: lovepro
 * Date: 2008-7-29
 * Time: 8:58
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;

namespace MethodParem
{
	public class Class1
	{
		public static void inc(int i)
		{
			i++;
		}
		public static void incf(ref int i)
		{
			// various i must be init before trans
			i++;
		}
		public static void inco(out int i)
		{
			i=2;	// various i must init before operate
			i++;
		}
		public static void changes(ref string s)
		{
			//s = "I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp!I like c sharp! like c sharp!";
			;
		}
		
		public static int MultiP(params int[] arr)
		{
			int r=0;
			foreach(int i in arr)
				r += i;
			return r;
		}
		
		public static int ArrayP(int[] arr)
		{
			int r=0;
			foreach(int i in arr)
				r += i;
			return r;
		}
		
		public static void Main()
		{
			int i=0, j=0, r;
			string s="Do you like c sharp?";
			inc(i);
			Console.WriteLine("Trans various by value, now i = {0}", i);
			
			incf(ref i);
			Console.WriteLine("Trans various by reference, now i = {0}", i);
			
			inco(out j);
			Console.WriteLine("Trans various by out, now i = {0}", j);
			
			Console.WriteLine("The string is {0}", s);
			changes(ref s);
			Console.WriteLine("Trans string by reference, now s = {0}", s);
			
			r = MultiP(1, 2 ,3 , 4, 5);
			Console.WriteLine("Call MultiP method result is {0}", r);
			
			int[] a = {2, 4, 6, 8, 10};
			r = ArrayP(a);
			Console.WriteLine("Call ArrayP method result is {0}", r);
		}
	}
	
}
